
public class Node {
	
	public Node next = null;
	public  int data;
	
	public Node(){
	}
	
	public Node(int d){
		this.data = d;
	}
	
	public Node appendToTail(Node head, int d){
		if(head == null) return null;
		
		Node newNode = new Node(d);
		Node n = head;
		while(n.next != null){
			n = n.next;
		}
		n.next = newNode;
		
		return head;
	}
	
	public Node deleteNode(Node head, int d){
		if(head == null) return null;
		if(head.data == d) return head.next;
		
		Node n = head;
		while(n.next != null){
			if(n.next.data == d) {
				n = n.next.next;
				return head;
			}
			n = n.next;
		}
		return head;
	}
	

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
